package com.example.webview_demos;
import android.os.Bundle;
import android.app.Activity;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.Window;
import android.view.WindowManager;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class MainActivity extends Activity {
	WebView mWebView,webview_base;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        
        
        initLayout();
        loadurl();
        loadDataWithBaseURL();
    }
    private void loadDataWithBaseURL() {
    	String data="<img src='https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=3905934274,1872499558&amp;fm=27&amp;gp=0.jpg'>";
    	webview_base.loadDataWithBaseURL(null, data, "text/html", "utf-8", null);
    	webview_base.setWebViewClient(new WebViewClient());
    	webview_base.getSettings().setJavaScriptEnabled(true);
	}
	private void loadurl() {
    	mWebView.loadUrl("http://176.122.140.84");
        mWebView.getSettings().setJavaScriptEnabled(true);
        mWebView.setWebViewClient(new WebViewClient());
		
	}
	private void initLayout() {
    	mWebView=(WebView) findViewById(R.id.webview);
    	webview_base=(WebView) findViewById(R.id.webview_base);
	}
	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if(keyCode==KeyEvent.KEYCODE_BACK&&mWebView.canGoBack()){
			mWebView.goBack();
			return true;
		}
		return super.onKeyDown(keyCode, event);
	}
	
}
